<template>
    <el-dialog :close-on-press-escape="false" :append-to-body="true" :visible="show" @opened="opened" @closed="closed" @close="show=false" :close-on-click-modal="false">
        <el-form ref="disTrade" label-position="right" label-width="120px" :model="disTrade" :rules="rules">
            <input type="hidden" :model="disTrade.id" />
            <el-form-item label="备注" prop="remark">
                <el-input v-model="disTrade.remark" placeholder="备注" style="width: 240px" />
            </el-form-item>
           
        </el-form>
        <div slot="footer">
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" :loading="modalLoading" @click="ok">确定</el-button>
        </div>
    </el-dialog>
</template>
<script>
    import { getTradeList, doPushTradeOrder,doRemarkTradeOrder } from "@/api/TradeApi"
export default {
    name: 'DisTrade',
    data() {
        return {

            show: false,
            modalLoading: false,
           
            disTrade: {
                remark:"",
                id:null
            },
            rules: {

            }
        };
    },
    mounted: function() {


    },
    methods: {
        
        opened() {

           

        },
        closed() {
            this.disTrade = {
                id:null,
                remark:""
            }
        },
        showDialog(id,remark) {
         
            this.disTrade.id=id;
            this.disTrade.remark=remark;
            this.show = true;
        },
        ok: function() {
            var ok = false;
            this.$refs['disTrade'].validate((valid) => {
                ok = valid;
                if (valid) {

                } else {
                    this.errorMessage('请认真填写数据');
                }
            })
            if (!ok) return;
            var me = this;

            me.modalLoading = true;
            doRemarkTradeOrder(me.disTrade).then(response => {
                var body = response;
                if (body.status == 0) {
                    me.successMessage("保存成功！");
                    me.show = false;
                    me.$emit("ok");

                } else {
                    me.errorMessage(body.info);
                }
                me.modalLoading = false;
            }, response => {
                me.modalLoading = false;
            });
        },
        cancel: function() {
           
            this.show = false;
            this.$emit("cancel");
        }
    }
}
</script>
<style scoped>
</style>